package com.funlog.designpattern.composite.demo02;

import java.util.ArrayList;
import java.util.List;

public class University extends OrganizationComponent {
    private List<OrganizationComponent> organizationComponents = new ArrayList<>();

    public University(String name, String des) {
        super(name, des);
    }

    @Override
    public void add(OrganizationComponent organizationComponent) {
        organizationComponents.add(organizationComponent);
    }

    @Override
    public void remove(OrganizationComponent organizationComponent) {
        organizationComponents.remove(organizationComponent);
    }

    @Override
    public void print() {
        System.out.println("===" + this.getName() + " : "+this.getDes());
        organizationComponents.stream().forEach(organizationComponent -> organizationComponent.print());
    }
}
